using UnityEngine;
using System.Collections;

/// \class  gkGUIRenderer
/// \brief 	The base component for GUI renderering
[ExecuteInEditMode()]
[AddComponentMenu("GK/Engine/Core/2D/Transform/gkGUIRenderer")]
[RequireComponent(typeof(gkScreenTransform))]
public class gkGUIBoxRenderer : MonoBehaviour
{	
	/// The box name
	public string text;
	
	/// The GUIStyle
	public string styleName;
	
	/// The box rectangle
	private Rect m_oBoxRectangle = new Rect(0,0,1,1);
	
	/// the screen transform
	protected gkScreenTransform m_rScreenTransform;
	
	/// \brief  Called after script loading
	void Start()
	{
		// Grab the screen transform
		m_rScreenTransform = GetComponent<gkScreenTransform>();
	}
	
	/// \brief  Display the GUI
	public void OnGUIRender()
	{	
		// Update the box rectangle
		m_oBoxRectangle.width = m_rScreenTransform.sizeInPixel.x;
		m_oBoxRectangle.height = m_rScreenTransform.sizeInPixel.y;
		
		// Position it
		// Center the box it on the screen position
		m_oBoxRectangle.x = m_rScreenTransform.positionInPixel.x - m_oBoxRectangle.width * 0.5f;
		m_oBoxRectangle.y = m_rScreenTransform.positionInPixel.y - m_oBoxRectangle.height * 0.5f;
		
		// Display the box
		GUI.Box(m_oBoxRectangle, text, "Action_Clip");
	}
}